/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.util.Objects;

/**
 *
 * @author Оксана
 */
public class Answer {
    private Integer id;
    private String text;
    private String letter;    
    private boolean correct;
    private Question question;
    
    public Answer() {}

    public Answer(Integer id, String text, String letter, boolean correct, Question question) {
        this.id = id;
        this.text = text;
        this.letter = letter;
        this.correct = correct;
        this.question = question;
    }   

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }    

    public String getLetter() {
        return letter;
    }

    public void setLetter(String letter) {
        this.letter = letter;
    }

    public boolean isCorrect() {
        return correct;
    }

    public void setCorrect(boolean correct) {
        this.correct = correct;
    }

    public Question getQuestion() {
        return question;
    }

    public void setQuestion(Question question) {
        this.question = question;
    }    

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Answer other = (Answer) obj;
        if (this.id != other.id) {
            return false;
        }
        if (!Objects.equals(this.text, other.text)) {
            return false;
        }
        if (!Objects.equals(this.letter, other.letter)) {
            return false;
        }
        if (this.correct != other.correct) {
            return false;
        }
        if (!Objects.equals(this.question.getId(), other.question.getId())) {
            return false;
        }
        return true;
    }    

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 29 * hash + Objects.hashCode(this.id);
        hash = 29 * hash + Objects.hashCode(this.text);
        hash = 29 * hash + Objects.hashCode(this.letter);
        hash = 29 * hash + (this.correct ? 1 : 0);
        hash = 29 * hash + Objects.hashCode(this.question);
        return hash;
    }
}
